package com.defangit.award.extend.wxmp.orm;

import com.defangit.openapis.wechat.mp.user.domain.UserInfo;
import laogen.hibernate.CommonFinder;
import laogen.hibernate.CommonService;
import org.hibernate.Criteria;
import org.hibernate.criterion.DetachedCriteria;
import org.hibernate.criterion.Restrictions;

import java.util.Collection;

/**
 * Created by zhangfagen on 2019/1/12.
 */
public class WxmpUserInfoService extends CommonService<UserInfo> {
    public WxmpuserInfoFinder findAll(){
        return new WxmpuserInfoFinder();
    }
    public class WxmpuserInfoFinder extends CommonFinder<UserInfo>{
        private DetachedCriteria criteria=detachedAll();
        @Override
        public Criteria getCriteria() {
            return criteria.getExecutableCriteria(getSession());
        }

        @Override
        public DetachedCriteria getDetachedCriteria() {
            return criteria;
        }

        public WxmpuserInfoFinder ids(Collection<String> ids){
            if(ids==null || ids.isEmpty()) return this;
            criteria=criteria.add(Restrictions.in("openid",ids));
            return this;
        }
    }
}
